package main

import (
	"mpps/services/srv-ProgramUpload/handler"
	pb "mpps/services/srv-ProgramUpload/proto"
	"mpps/tools/config"
	"mpps/tools/middleware"
	"mpps/tools/registry"
	"time"

	"github.com/asim/go-micro/v3"
	"github.com/asim/go-micro/v3/logger"
	"github.com/asim/go-micro/v3/transport"
)

func main() {
	register := registry.GetRegistry()
	// Create service
	srv := micro.NewService(
		micro.Name(config.ProgramUploadSrv),
		micro.Version("latest"),
		micro.RegisterTTL(time.Second*30),
		micro.RegisterInterval(time.Second*30),
		micro.Registry(register),
		micro.WrapHandler(middleware.SrvAuthMiddleware),
		micro.Transport(
			transport.NewHTTPTransport(
				transport.Secure(true),
			),
		),
	)

	srv.Init()

	// Register handler
	pb.RegisterProgramUploadHandler(srv.Server(), handler.NewProgramUpload())

	// Run service
	if err := srv.Run(); err != nil {
		logger.Fatal(err)
	}
}
